package com.ruoyi.rsikManage.service.Impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.rsikManage.domain.MonitorPoint;
import com.ruoyi.rsikManage.mapper.MonitorPointMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.rsikManage.mapper.TVcrDataMapper;
import com.ruoyi.rsikManage.domain.TVcrData;
import com.ruoyi.rsikManage.service.ITVcrDataService;

/**
 * vcrService业务层处理
 *
 * @author sxygsj
 * @date 2024-06-25
 */
@Service
public class TVcrDataServiceImpl implements ITVcrDataService
{
    @Autowired
    private TVcrDataMapper tVcrDataMapper;

    @Autowired
    private MonitorPointMapper monitorPointMapper;

    /**
     * 查询vcr
     *
     * @param id vcr主键
     * @return vcr
     */
    @Override
    public TVcrData selectTVcrDataById(Long id)
    {
        return tVcrDataMapper.selectTVcrDataById(id);
    }

    /**
     * 查询vcr列表
     *
     * @param tVcrData vcr
     * @return vcr
     */
    @Override
    public List<TVcrData> selectTVcrDataList(TVcrData tVcrData)
    {
        return tVcrDataMapper.selectTVcrDataList(tVcrData);
    }

    /**
     * 新增vcr
     *
     * @param tVcrData vcr
     * @return 结果
     */
    @Override
    public int insertTVcrData(TVcrData tVcrData)
    {
        tVcrData.setCreateTime(DateUtils.getNowDate());
        return tVcrDataMapper.insertTVcrData(tVcrData);
    }

    /**
     * 修改vcr
     *
     * @param tVcrData vcr
     * @return 结果
     */
    @Override
    public int updateTVcrData(TVcrData tVcrData)
    {
        return tVcrDataMapper.updateTVcrData(tVcrData);
    }

    /**
     * 批量删除vcr
     *
     * @param ids 需要删除的vcr主键
     * @return 结果
     */
    @Override
    public int deleteTVcrDataByIds(Long[] ids)
    {
        return tVcrDataMapper.deleteTVcrDataByIds(ids);
    }

    @Override
    public List<TVcrData> getVcrByApeId(String apeId) {
        MonitorPoint monitorPoint = new MonitorPoint();
        monitorPoint.setApeId(apeId);
        List<MonitorPoint> monitorPoints = monitorPointMapper.selectAllMonitorPoints2(monitorPoint);
        String ownerApsName = monitorPoints.get(0).getOwnerApsName();
        String idx = monitorPoints.get(0).getIdx();

        TVcrData tVcrData = new TVcrData();
        tVcrData.setVcrName(ownerApsName);
        List<TVcrData> tVcrData1 = tVcrDataMapper.selectTVcrDataList(tVcrData);
        tVcrData1.get(0).setApeId(apeId);
        tVcrData1.get(0).setIdx(idx);
        return tVcrData1;
    }


}
